<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    function SuperType () {
        this.property = true
    }
    SuperType.prototype.getSuperValue = function () {
        return this.property
    }
    function SubType () {
        this.subproperty = false
    }

    console.log('继承前', SubType.prototype)
    SubType.prototype = new SuperType() // 重写了SubType的原型对象
    console.log('继承后', SubType.prototype)
    SubType.prototype.getSubValue = function () { // 添加的方法
        return this.subproperty
    }

    // 相当于SuperType实例的property属性
    console.log(SubType.prototype.property)     // true
    var sub = new SubType()
    console.log(sub.property, sub.subproperty)  // true false
    console.log(sub.getSubValue(), sub.getSuperValue()) //false true

    // var instance = new SubType()
    // console.log(instance.subproperty)
    // console.log(instance.getSubValue())
    // console.log(instance.getSuperValue())
    // console.log(instance.getSubValue())

</script>

</body>
</html>
